<div class="modal-header">
	<h5 class="modal-title" id="exampleModalLabel">{$data['id']>0 ? '编辑模板' : '新建模板'}</h5>
	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
</div>
<div class="modal-body">
	<div class="form-group row">
		<label for="template_name" class="col-sm-3 col-form-label text-right">模板名称</label>
		<div class="col-sm-4">
			<input class="form-control" type="text" id="template_name" name="template_name" value="{$data.template_name}">
		</div>
	</div>
    <div class="form-group row">
        <label for="cpn_type" class="col-sm-3 col-form-label text-right">单元类型</label>
        <div class="col-sm-8">
   
              <select id="cpn_type" name="cpn_type" class="form-control"  onchange="Onchanges()">
                      <volist name="cpn_class" id="r">
                         <option value="{$r[class_id]}" <if condition="$data['cpn_type'] eq $r['class_id']">selected</if>>{$r[class_name]}</option>
                      </volist>
              </select>
        </div>
    </div>
    <div class="form-group row">
        <label for="group_code" class="col-sm-3 col-form-label text-right">专用设备控制器类型</label>
        <div class="col-sm-8">
             <select id="group_code" name="group_code" class="form-control" >
                      <option value="">请选择</option>                     
             </select>
        </div>
    </div>
    <div class="form-group row">

        <label for="cpn" class="col-sm-3 col-form-label text-right">CPN类型</label>
        <div class="col-sm-8">
              <select id="cpn" name="cpn" class="form-control" >
              <option value="CPN-A" <if condition="$data['cpn'] eq 'CPN-A'">selected</if>>CPN-A</option>        
              <option value="CPN-B" <if condition="$data['cpn'] eq 'CPN-B'">selected</if>>CPN-B</option>
              </select>
        </div>
    </div>
     
           
	
	<div class="form-group row">

		<label for="dec" class="col-sm-3 col-form-label text-right">模板描述</label>
		<div class="col-sm-8">
			<textarea class="form-control" id="dec" name="dec" rows="3">{$data.dec}</textarea>
		</div>
	</div>
</div>
<div class="modal-footer">
	<input type="hidden" name="act" value="{$data['id'] ? 'edit' : 'add'}" />
	<input type="hidden" name="id" value="{$data.id}" />
    <input type="hidden" name="module_id" value="{$module_id}" />
	<button type="submit" class="btn btn-info px-4 align-self-center report-btn">{$data['id'] ? '立即保存' : '立即创建'}</button>
</div>
<script>
    //根据变量类型获取分组
    function Onchanges(){
        var url = "{:U('SetParam/getGroupCode')}";
        var select = $('#group_code');
        var group_code = "{$data.group_code}";
        var cpn_param_id = "{$datalist.cpn_param_id}";
        $.get(url, {cpn_type: $("#cpn_type").val()}, function(res){
            if(res){

                select.html('<option value="">请选择</option>');
                $.each(res, function(i, v){
                    if(group_code == i){
                        select.append('<option  value="'+i+'" selected>'+v+'</option>');
                    }else{
                        select.append('<option  value="'+i+'">'+v+'</option>');
                    }
                });
            }
        }, 'json');
    }
    
    Onchanges();
</script>
